﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CluelessGame
{
    [Serializable]
    public class Character : ObjectWithLocation
    {
        public string Name;

        private Player _associatedPlayer = null;
        public Player AssociatedPlayer
        {
            get { return _associatedPlayer; }
            set
            {
                if (_associatedPlayer != value)
                {
                    _associatedPlayer = value;
                    if (_associatedPlayer != null)
                    {
                        _associatedPlayer.AssociatedCharacter = this;
                    }
                }
            }
        }

        private CharacterCard _associatedCard;
        public CharacterCard AssociatedCard
        {
            get { return _associatedCard; }
            set { _associatedCard = value; }
        }

        public static bool operator == (Character a, Character b)
        {
            if ((object)a == null && (object)b == null)
                return true;
            if ((object)a == null || (object)b == null)
                return false;
            return a.Name == b.Name;
        }

        public static bool operator != (Character a, Character b)
        {
            if ((object)a == null && (object)b == null)
                return false;
            if ((object)a == null || (object)b == null)
                return true;
            return a.Name != b.Name;
        }

        public override bool Equals(object obj)
        {
            return this == obj as Character;
        }

        public Character()
        {

        }
    }
}
